'''
Created on Mar 31, 2012

@author: e911miri
'''

import cherrypy
from jinja2 import Environment, FileSystemLoader
from __init__ import result

env = Environment(loader=FileSystemLoader('templates'))

class Blog:
    @cherrypy.expose
    def index(self):
        tmpl = env.get_template('index.html')
        return tmpl.render(salutation='Frist Blog', target='from tomiwa with love')

class Hello:
    @cherrypy.expose
    def index(self):
        tmpl = env.get_template('index.html')
        return tmpl.render()
    
    @cherrypy.expose
    def result(self, reg_num=None,year=None, pin=None):
        year=cherrypy.request.cache['year']
        if reg_num and pin:
            r = result(reg_num=reg_num, pin=pin)
        else:
            r={'error': 'unavailable'}
        tmpl = env.get_template('resultpage.html')
        return tmpl.render(r)
        
